var fs = require('fs');

//同步创建文件时间计算
let SyncstarTime = new Date().getTime()

for (let index = 1; index <= 1000; index++) {
    
    fs.writeFileSync("./test/test"+index+".text","holle")
}


let SyncendTime = new Date().getTime()


console.log("同步耗时"+(SyncendTime-SyncstarTime));



//异步创建文件计时

let starTime = new Date().getTime()
let num=0
for (let index = 1; index <=1000; index++) {
    
    fs.writeFile("./test/texts"+index+".text","bye",function (err) {
        num++;
    if (num==1000) {
        let endTime= new Date().getTime()
        console.log("异步耗时"+(endTime-starTime));
    }
    })
    

}
